/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Paul
 */
@Entity
@Table(name = "session")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Session.findAll", query = "SELECT s FROM Session s"),
    @NamedQuery(name = "Session.findByIdSession", query = "SELECT s FROM Session s WHERE s.idSession = :idSession"),
    @NamedQuery(name = "Session.findByDateDebutSession", query = "SELECT s FROM Session s WHERE s.dateDebutSession = :dateDebutSession"),
    @NamedQuery(name = "Session.findByDateFinSession", query = "SELECT s FROM Session s WHERE s.dateFinSession = :dateFinSession"),
    @NamedQuery(name = "Session.findByPeriodeInscriptionSession", query = "SELECT s FROM Session s WHERE s.periodeInscriptionSession = :periodeInscriptionSession")})
public class Session implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idSession")
    private Integer idSession;
    @Basic(optional = false)
    @NotNull
    @Column(name = "dateDebutSession")
    @Temporal(TemporalType.DATE)
    private Date dateDebutSession;
    @Basic(optional = false)
    @NotNull
    @Column(name = "dateFinSession")
    @Temporal(TemporalType.DATE)
    private Date dateFinSession;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 25)
    @Column(name = "periodeInscriptionSession")
    private String periodeInscriptionSession;
    @ManyToMany(mappedBy = "sessionCollection")
    private Collection<Formation> formationCollection;
    @ManyToMany(mappedBy = "sessionCollection")
    private Collection<Cursus> cursusCollection;

    public Session() {
    }

    public Session(Integer idSession) {
        this.idSession = idSession;
    }

    public Session(Integer idSession, Date dateDebutSession, Date dateFinSession, String periodeInscriptionSession) {
        this.idSession = idSession;
        this.dateDebutSession = dateDebutSession;
        this.dateFinSession = dateFinSession;
        this.periodeInscriptionSession = periodeInscriptionSession;
    }

    public Integer getIdSession() {
        return idSession;
    }

    public void setIdSession(Integer idSession) {
        this.idSession = idSession;
    }

    public Date getDateDebutSession() {
        return dateDebutSession;
    }

    public void setDateDebutSession(Date dateDebutSession) {
        this.dateDebutSession = dateDebutSession;
    }

    public Date getDateFinSession() {
        return dateFinSession;
    }

    public void setDateFinSession(Date dateFinSession) {
        this.dateFinSession = dateFinSession;
    }

    public String getPeriodeInscriptionSession() {
        return periodeInscriptionSession;
    }

    public void setPeriodeInscriptionSession(String periodeInscriptionSession) {
        this.periodeInscriptionSession = periodeInscriptionSession;
    }

    @XmlTransient
    public Collection<Formation> getFormationCollection() {
        return formationCollection;
    }

    public void setFormationCollection(Collection<Formation> formationCollection) {
        this.formationCollection = formationCollection;
    }

    @XmlTransient
    public Collection<Cursus> getCursusCollection() {
        return cursusCollection;
    }

    public void setCursusCollection(Collection<Cursus> cursusCollection) {
        this.cursusCollection = cursusCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idSession != null ? idSession.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Session)) {
            return false;
        }
        Session other = (Session) object;
        if ((this.idSession == null && other.idSession != null) || (this.idSession != null && !this.idSession.equals(other.idSession))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Session[ idSession=" + idSession + " ]";
    }
    
}
